package com.admin.controller.admin.photo;

import com.system.constant.HTTPStatus;
import com.system.entity.photo.Photo;
import com.system.response.Result;
import com.system.response.photo.PhotoDtoResponse;
import com.system.service.photo.PhotoService;
import com.system.util.AliyunUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.constraints.NotNull;

@RestController
@RequestMapping("/sys/photo")
public class PhotoController {
    @Autowired
    private PhotoService photoService;

    @PostMapping("/photoList")
    public Result photoList(@RequestBody PhotoDtoResponse photoDtoResponse) {
        Result result = photoService.photoList(photoDtoResponse);
        return result;
    }

    /**
     * 前端上传图片
     *
     * @param photo
     * @return
     */
    @PostMapping("/frontend/addPhoto")
    public Result frontendAddPhoto(@Validated @RequestBody Photo photo) {
        return photoService.frontendAddPhoto(photo);
    }

    /**
     * 后端上传图片
     *
     * @param photo
     * @return
     */
    @PostMapping("/backend/addPhoto")
    public Result backendAddPhoto(@Validated @RequestBody Photo photo) {
        return photoService.backendAddPhoto(photo);
    }


    @DeleteMapping("/deletePhoto")
    public Result deletePhoto(@NotNull(message = "编号不能为空") Integer id, @NotNull(message = "状态不能为空") Integer isDelete) {
        return photoService.deletePhoto(id, isDelete);
    }


}
